// 用户相关接口
var express = require('express');
const newsController = require('../../controllers/admin/newsControllers');
var newsRouter = express.Router();

const multer  = require('multer')
const upload = multer({ dest: 'public/newsUploads/' })


// 添加新闻接口,涉及文件上传
newsRouter.post('/news/add', upload.single('file'),newsController.add) 

// 获取新闻列表接口
newsRouter.get('/news/list',newsController.list) 

// 切换发布状态接口
newsRouter.put('/news/publish',newsController.publish)

// 删除新闻接口
newsRouter.delete('/news/delete',newsController.delete)

// 获取新闻详情接口
newsRouter.get('/news/detail',newsController.detail)

// 更新新闻接口
newsRouter.put('/news/update',upload.single('file'),newsController.update)

module.exports = newsRouter;